package com.yyk.yykywd.mvvm.view_model

import com.yyk.yykywd.bean.BaseBean
import com.yyk.yykywd.mvvm.entity.TypeBean
import com.yyk.yykywd.mvvm.model.GetBase
import com.yyk.yykywd.mvvm.model.CustomerModel
import java.util.*
import kotlin.collections.ArrayList

/**
 * 文件描述：
 * Created by guo on 2019-11-30.
 */
class AddCustomerViewModel : BaseViewModel() {
    private val addCustomerModel = CustomerModel()

    var hospitalType: List<String> = ArrayList()
    var hospitalGrade: List<String> = ArrayList()
    var agentType: List<String> = ArrayList()
    var agentTypeId: List<Int> = ArrayList()
    var selectedTypePosition: Int = 0
    var agentSource: List<String> = ArrayList()
    val startDate: Calendar = Calendar.getInstance()
    val endDate: Calendar = Calendar.getInstance()

    init {
        startDate.set(2019, 10, 1)
        endDate.set(2050, 11, 31)
    }

    fun addHospitalClient(hos_name: String,
                          type_name: String,
                          grade_name: String,
                          call_time: String,
                          call_name: String,
                          call_grade: String,
                          call_phone: String,
                          hos_text: String,
                          flag: String) {
        addCustomerModel.addHospitalClient(hos_name,
                type_name,
                grade_name,
                call_time,
                call_name,
                call_grade,
                call_phone,
                hos_text,
                flag, object : GetBase {
            override fun getInfo(base: BaseBean) {
                setBaseValue(base)
            }

            override fun onError(e: String) {

            }

        })
    }

    fun addAgentClient(status: Int,
                       name: String,
                       phone: String,
                       area: String,
                       source: String,
                       trade: String,
                       desc: String,
                       flag: String) {
        addCustomerModel.addAgentClient(status,
                name,
                phone,
                area,
                source,
                trade,
                desc,
                flag, object : GetBase {
            override fun getInfo(base: BaseBean) {
                setBaseValue(base)
            }

            override fun onError(e: String) {
            }

        })
    }

    fun getType() {
        addCustomerModel.getType(object : CustomerModel.GetType {
            override fun getInfo(type: TypeBean) {
                hospitalType = type.data.hos_type.map { it.name }
                hospitalGrade = type.data.hos_grade.map { it.name }
                agentType = type.data.agent_type.map { it.name }
                agentTypeId = type.data.agent_type.map { it.id }
                agentSource = type.data.agent_ly.map { it.name }
            }

            override fun onError(e: String) {
            }

        })
    }

    fun claimHospitalCustomer(id: String,
                              hos_type: String,
                              hos_grade: String,
                              call_time: String,
                              call_name: String,
                              call_phone: String,
                              call_grade: String,
                              hos_text: String) {
        addCustomerModel.claimHospitalCustomer(id, hos_type, hos_grade, call_time, call_name, call_phone, call_grade, hos_text, object : GetBase {
            override fun getInfo(base: BaseBean) {
                setBaseValue(base)
            }

            override fun onError(e: String) {
            }
        })
    }

    fun claimAgentCustomer(id: String,
                           phone: String,
                           area: String,
                           source: String,
                           trade: String,
                           desc: String) {
        addCustomerModel.claimAgentCustomer(id, phone, area, source, trade, desc, object : GetBase {
            override fun getInfo(base: BaseBean) {
                setBaseValue(base)
            }

            override fun onError(e: String) {
            }
        })
    }
}